package com.tony.boot.resolver;

import com.coxautodev.graphql.tools.GraphQLResolver;
import com.tony.boot.entity.Author;
import com.tony.boot.entity.Book;
import com.tony.boot.repository.AuthorRepository;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Set;

public class BookResolver implements GraphQLResolver<Book> {
    @Autowired
    private AuthorRepository authorRepository;
    public BookResolver(AuthorRepository authorRepository){
        this.authorRepository = authorRepository;
    }

    public Set<Author> getAuthors(Book book) {
        return book.getAuthors();
    }
}
